<?php
namespace app\common\model;


class ConfigComm extends BaseCommon
{
    ///主键id
    protected $pk = 'id';
    ///表名
    protected $table = 'dh_config';


    ///获取公共配置
    public function bathVar(){
        return $this->where('config_position','in','comm,seo')
            ->column('config_code,config_value');
    }




    ///获取指定条件的列表数
    public function getIndexDataListByWhereMap($map){
        return $this->where($map)
            ->column('id,config_code,config_position,config_title,config_value,config_description,create_time,update_time', 'id');
    }



    ///获取列表页数据
    public function getIndexDataList(){
        return $this->where('config_position','in','comm,seo')
            ->column('id,config_code,config_position,config_title,config_value,config_description,create_time,update_time', 'id');
    }


    ///获取指定code数据{返回字符串}
    public function getStringValByCode($code = ''){
        return $this->where('config_code',$code)
            ->field('config_value')
            ->find()
            ->getAttr('config_value');
    }

    ///获取指定code数据{返回数组}
    public function getDataByCode($code = ''){
        return $this->where('config_code',$code)
            ->field('config_value')
            ->find();
    }

    ///获取模板配置数据
    public function getTemplateConfigDataList(){
        return $this->where('config_position','template_config')
            ->field('id,config_title,config_value')
            ->select();
    }


}